package com.medicine.web.controller.manage;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.medicine.common.annotation.Log;
import com.medicine.common.core.controller.BaseController;
import com.medicine.common.core.domain.AjaxResult;
import com.medicine.common.enums.BusinessType;
import com.medicine.manage.domain.OrderConfirm;
import com.medicine.manage.service.IOrderConfirmService;
import com.medicine.common.utils.poi.ExcelUtil;
import com.medicine.common.core.page.TableDataInfo;

/**
 * 订单确认Controller
 * 
 * @author admin
 * @date 2024-10-13
 */
@RestController
@RequestMapping("/manage/confirm")
public class OrderConfirmController extends BaseController
{
    @Autowired
    private IOrderConfirmService orderConfirmService;


    /**
     * 查询订单确认列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OrderConfirm orderConfirm)
    {
        startPage();
        List<OrderConfirm> list = orderConfirmService.selectOrderConfirmList(orderConfirm);
        return getDataTable(list);
    }

    /**
     * 导出订单确认列表
     */
    @Log(title = "订单确认", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderConfirm orderConfirm)
    {
        List<OrderConfirm> list = orderConfirmService.selectOrderConfirmList(orderConfirm);
        ExcelUtil<OrderConfirm> util = new ExcelUtil<OrderConfirm>(OrderConfirm.class);
        util.exportExcel(response, list, "订单确认数据");
    }

    /**
     * 获取订单确认详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderConfirmService.selectOrderConfirmById(id));
    }

    /**
     * 新增订单确认
     */
    @Log(title = "订单确认", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderConfirm orderConfirm)
    {
        return toAjax(orderConfirmService.insertOrderConfirm(orderConfirm));
    }

    /**
     * 修改订单确认
     */
    @Log(title = "订单确认", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderConfirm orderConfirm)
    {
        return toAjax(orderConfirmService.updateOrderConfirm(orderConfirm));
    }

    /**
     * 删除订单确认
     */
    @Log(title = "订单确认", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderConfirmService.deleteOrderConfirmByIds(ids));
    }
}
